<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('区域管理')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<style>
    .bootstrap-tree-table .treetable-tbody td {
        white-space: normal !important;
    }

    .bootstrap-tree-table .treetable-bars .tool-right {
        float: left !important;
        left: 10px;
    }

    .table-striped .table > thead:first-child > tr:first-child > th {
        font-weight: normal;
        font-size: 13px;
        border: 1px solid #cccccc !important;
    }

    .bootstrap-tree-table .treetable-tbody td {
        border: 1px solid #cccccc !important;
        border-top: 0px solid #cccccc !important;
    }

    .select-list li p {
        width: 20px !important;
    }

</style>
<body class="gray-bg">

<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 项目名称
            </div>
            <div class="box-tools pull-right">
                <a type="button" class="btn btn-box-tool" href="#" onclick="project()" title="管理项目"><i
                        class="fa fa-edit"></i></a>
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
                        class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
                        class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新项目"><i
                        class="fa fa-refresh"></i></button>
            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>


<div class="ui-layout-center">
    <div class="container-div">

        <div class="row">
            <!--隐藏区-->
            <input type="hidden" id="companyId" name="companyId">
            <input type="hidden" id="companyName" name="companyName">
            <input type="hidden" id="proId" name="proId">
            <input type="hidden" id="programId" name="programId">
            <input type="hidden" id="programName" name="programName">

            <div class="col-sm-12 search-collapse">
                <div class="tabs-container">

                    <!--选项卡-->
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab-0" aria-expanded="true">所有工艺</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-1" aria-expanded="false"> 混凝土</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">砌体</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">抹灰</a></li>
                    </ul>

                    <!--内容区-->
                    <div class="tab-content">
                        <!--所有工艺-->
                        <div id="tab-0" class="tab-pane active">

                            <!--筛选条件-->
                            <div class="col-sm-12 search-collapse">
                                <form id="region-form0">
                                    <div class="select-list">

                                        <input type="hidden" id="companyId0" name="companyId">
                                        <input type="hidden" id="companyName0" name="companyName">
                                        <input type="hidden" id="proId0" name="proId">
                                        <input type="hidden" id="programId0" name="programId">
                                        <input type="hidden" id="programName0" name="programName">

                                        <ul>
                                            <li>
                                                <p style="width: 90px !important;">项目名称：</p>
                                                <div class="col-lg-2" style="margin-left: -15px">
                                                    <input type="text" class="form-control" name="programName" id="progName0" autocomplete='off'/>
                                                </div>
                                            </li>

                                            <li>
                                                <p style="width: 90px !important;" >工艺类型：</p>
                                                <select name="type" th:with="type=${@dict.getType('tech_type')}">
                                                    <option value="">所有</option>
                                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                                </select>
                                            </li>

                                            <li style="margin-left: -15px">
                                                <p style="width: 90px !important;" >工程部位：</p>
                                                <input type="text" name="buildingNumber" class="form-control"
                                                       autocomplete='off'>
                                            </li>
                                            <li>
                                                <p style="width: 90px !important;">结构部位：</p>
                                                <input type="text" name="floorNumber" class="form-control"
                                                       autocomplete='off' onkeyup="value=value.replace(/[^\d]/g,'')">
                                            </li>

                                            <li>
                                                <p style="width: 90px !important;">浇筑日期：</p>
                                                <input type="text" id="pouringTime0" name="pouringTime" class="form-control" autocomplete='off'>

                                            </li>

                                            <li class="select-time" >
                                                <label style="margin-left: 40px">创建时间： </label>
                                                <input type="text" class="time-input" id="startTime0" placeholder="开始时间" name="beginTime" autocomplete='off'/>
                                                <span>-</span>
                                                <input type="text" class="time-input" id="endTime0" placeholder="结束时间" name="endTime" autocomplete='off'/>
                                            </li>

                                            <li style="margin-left: 50px">
                                                <a class="btn btn-primary btn-rounded btn-sm" id="search0" onclick="$.table.search('region-form0', 'bootstrap-table0')" ><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('region-form0', 'bootstrap-table0')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="exportExcelAll('工艺实测统计表')">
                                                    <i class="fa fa-download"></i> 导出
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </form>
                            </div>

                            <!--按钮区-->
                            <div class="btn-group-sm" id="toolbar0" role="group">
                                <a class="btn btn-warning" onclick="exportOutlineExcel('工艺实测汇总统计表')">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </div>

                            <!--表格区-->
                            <div class="col-sm-12 table-bordered" style="margin-top: 30px">
                                <table id="bootstrap-table0"></table>
                            </div>
                        </div>
                        <!--混凝土-->
                        <div id="tab-1" class="tab-pane">
                            <div class="col-sm-12 search-collapse">
                                <form id="region-form">
                                    <div class="select-list">
                                        <input type="hidden" id="companyId1" name="companyId">
                                        <input type="hidden" id="companyName1" name="companyName">
                                        <input type="hidden" id="proId1" name="proId">
                                        <input type="hidden" id="programId1" name="programId">
                                        <input type="hidden" id="programName1" name="programName">

                                        <ul>
                                            <li>
                                                <p style="width: 90px !important;">项目名称：</p>
                                                <div class="col-lg-2" style="margin-left: -15px">
                                                    <input type="text" class="form-control" name="programName" id="progName" autocomplete='off'/>
                                                </div>
                                            </li>
                                            <li style="margin-left: -15px">
                                                <p style="width: 90px !important;" >工程部位：</p>
                                                <input type="text" name="buildingNumber" class="form-control"
                                                       autocomplete='off' >
                                            </li>
                                            <li>
                                                <p style="width: 90px !important;">结构部位：</p>
                                                <input type="text" name="floorNumber" class="form-control"
                                                       autocomplete='off' onkeyup="value=value.replace(/[^\d]/g,'')">
                                            </li>

                                            <li>
                                                <p style="width: 90px !important;">浇筑日期：</p>
                                                <input type="text" id="pouringTime" name="pouringTime" class="form-control" autocomplete='off'>

                                            </li>

                                            <li class="select-time" >
                                                <label style="margin-left: 30px">创建时间： </label>
                                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
                                                <span>-</span>
                                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                                            </li>

                                            <li style="margin-left: 50px">
                                                <a class="btn btn-primary btn-rounded btn-sm" id="search" onclick="$.table.search('region-form', 'bootstrap-table')" ><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('region-form', 'bootstrap-table')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="exportExcelAll('工艺实测统计表')">
                                                    <i class="fa fa-download"></i> 导出
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                            <div class="btn-group-sm" id="toolbar" role="group">
                                <a class="btn btn-success" id="add"
                                   onclick="addConcreteView($('#companyId').val(),$('#proId').val(),$('#programName').val())">
                                    <i class="fa fa-plus"></i> 新增
                                </a>
                                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                                    <i class="fa fa-remove"></i> 删除
                                </a>

                                <a class="btn btn-warning" onclick="exportExcel('混凝土实测统计表')">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </div>
                            <div class="col-sm-12 table-bordered" style="margin-top: 30px">
                                <table id="bootstrap-table"></table>
                            </div>
                        </div>
                        <!--砌体-->
                        <div id="tab-2" class="tab-pane">
                            <div class="col-sm-12 search-collapse">
                                <form id="region-form1">
                                    <div class="select-list">

                                        <input type="hidden" id="companyId2" name="companyId">
                                        <input type="hidden" id="companyName2" name="companyName">
                                        <input type="hidden" id="proId2" name="proId">
                                        <input type="hidden" id="programId2" name="programId">
                                        <input type="hidden" id="programName2" name="programName">

                                        <ul>
                                            <li>
                                                <p style="width: 90px !important;">项目名称：</p>
                                                <div class="col-lg-2" style="margin-left: -15px">
                                                    <input type="text" class="form-control" name="programName" id="progName1" autocomplete='off'/>
                                                </div>

                                            </li>
                                            <li style="margin-left: -15px">
                                                <p style="width: 90px !important;" >工程部位：</p>
                                                <input type="text" name="buildingNumber" class="form-control"
                                                       autocomplete='off'>
                                            </li>
                                            <li>
                                                <p style="width: 90px !important;">结构部位：</p>
                                                <input type="text" name="floorNumber" class="form-control"
                                                       autocomplete='off' onkeyup="value=value.replace(/[^\d]/g,'')">
                                            </li>

                                            <li>
                                                <p style="width: 90px !important;">完成时间：</p>
                                                <input type="text" name="pouringTime" id="pouringTime1" class="form-control" autocomplete='off'>

                                            </li>

                                            <li class="select-time" >
                                                <label style="margin-left: 30px">创建时间： </label>
                                                <input type="text" class="time-input" placeholder="开始时间" name="beginTime"/>
                                                <span>-</span>
                                                <input type="text" class="time-input" placeholder="结束时间" name="endTime"/>
                                            </li>

                                            <li style="margin-left: 50px">
                                                <a class="btn btn-primary btn-rounded btn-sm" id="search1" onclick="$.table.search('region-form1', 'bootstrap-table1')" ><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('region-form1', 'bootstrap-table1')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="exportExcelAll('工艺实测统计表')">
                                                    <i class="fa fa-download"></i> 导出
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                            <div class="btn-group-sm" id="toolbar1" role="group">
                                <a class="btn btn-success" id="add1"
                                   onclick="addBrickView($('#companyId').val(),$('#proId').val(),$('#programName').val())">
                                    <i class="fa fa-plus"></i> 新增
                                </a>
                                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                                    <i class="fa fa-remove"></i> 删除
                                </a>

                                <a class="btn btn-warning" onclick="exportBrickExcel('砌体实测统计表')">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </div>
                            <div class="col-sm-12 table-bordered" style="margin-top: 30px">
                                <table id="bootstrap-table1"></table>
                            </div>
                        </div>
                        <!--抹灰-->
                        <div id="tab-3" class="tab-pane">
                            <div class="col-sm-12 search-collapse">
                                <form id="region-form2">
                                    <div class="select-list">

                                        <input type="hidden" id="companyId3" name="companyId">
                                        <input type="hidden" id="companyName3" name="companyName">
                                        <input type="hidden" id="proId3" name="proId">
                                        <input type="hidden" id="programId3" name="programId">
                                        <input type="hidden" id="programName3" name="programName">

                                        <ul>
                                            <li>
                                                <p style="width: 90px !important;">项目名称：</p>
                                                <div class="col-lg-2" style="margin-left: -15px">
                                                    <input type="text" class="form-control" name="programName" id="progName2" autocomplete='off'/>
                                                </div>

                                            </li>
                                            <li style="margin-left: -15px">
                                                <p style="width: 90px !important;" >工程部位：</p>
                                                <input type="text" name="buildingNumber" class="form-control"
                                                       autocomplete='off' >
                                            </li>
                                            <li>
                                                <p style="width: 90px !important;">结构部位：</p>
                                                <input type="text" name="floorNumber" class="form-control"
                                                       autocomplete='off' onkeyup="value=value.replace(/[^\d]/g,'')">
                                            </li>

                                            <li>
                                                <p style="width: 90px !important;">完成时间：</p>
                                                <input type="text" name="pouringTime" id="pouringTime2" class="form-control" autocomplete='off'>

                                            </li>

                                            <li class="select-time" >
                                                <label style="margin-left: 30px">创建时间： </label>
                                                <input type="text" class="time-input" placeholder="开始时间" name="beginTime"/>
                                                <span>-</span>
                                                <input type="text" class="time-input" placeholder="结束时间" name="endTime"/>
                                            </li>

                                            <li style="margin-left: 50px">
                                                <a class="btn btn-primary btn-rounded btn-sm" id="search2" onclick="$.table.search('region-form2', 'bootstrap-table2')" ><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('region-form2', 'bootstrap-table2')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="exportExcelAll('工艺实测统计表')">
                                                    <i class="fa fa-download"></i> 导出
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                            <div class="btn-group-sm" id="toolbar2" role="group">
                                <a class="btn btn-success" id="add2"
                                   onclick="addPlasterView($('#companyId').val(),$('#proId').val(),$('#programName').val())">
                                    <i class="fa fa-plus"></i> 新增
                                </a>
                                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                                    <i class="fa fa-remove"></i> 删除
                                </a>

                                <a class="btn btn-warning" onclick="exportPlasterExcel('抹灰实测统计表')">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </div>
                            <div class="col-sm-12 table-bordered" style="margin-top: 30px">
                                <table id="bootstrap-table2"></table>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-suggest-js" />
<th:block th:include="include :: bootstrap-typeahead-js" />


<script th:inline="javascript">

    /* 模块前缀url */
    var prefix = ctx + "concreteCheckManage";

    /* 初始化字典:工艺类型 */
    var types = [[${@dict.getType('tech_type')}]];

    /* 初始化:获取所有工程公司下的项目名称 */
    $.get(ctx + "concreteManage/collection", function(data){
        $("#progName0").typeahead({
            source: data.value
        });

        $("#progName").typeahead({
            source: data.value
        });

        $("#progName1").typeahead({
            source: data.value
        });

        $("#progName2").typeahead({
            source: data.value
        });
    },'json');

    /* 初始化方法 */
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 300});

        // 初始化列表
        queryTotalList();
        queryConcreteList();
        queryBrickList();
        queryPlasterList();

        // 初始化树组件
        queryProjectTree();

        // 初始化日期控件
        formatDate();

        // 隐藏添加按钮
        $('#add').hide();
    });

    /* 初始化 汇总项信息 */
    function queryTotalList() {
        formatDate();

        var options = {
            id:"bootstrap-table0",
            toolbar: "toolbar0",
            uniqueId: "checkId",
            url: prefix + "/listTotal",
            createUrl: prefix + "/add{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            pagination: true,
            modalName: "所有工艺实测报表",
            columns: [
                [
                    {
                        checkbox: true,
                        rowspan: 2,
                        valign: "middle",
                        align: 'center'
                    },
                    {
                        field: 'checkId',
                        align: 'center',
                        title: '主键',
                        rowspan: 2,
                        valign: "middle",
                        visible: false
                    },
                    {
                        field: 'companyName',
                        align: 'center',
                        title: '工程公司',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'programName',
                        align: 'center',
                        title: '项目名称',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'type',
                        align: 'center',
                        title: '工艺类型',
                        rowspan: 2,
                        valign: "middle",
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(types, value);
                        }
                    },
                    {
                        field: 'buildingNumber',
                        align: 'center',
                        title: '工程部位',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'floorNumber',
                        align: 'center',
                        title: '结构部位',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'pouringTime',
                        align: 'center',
                        title: '浇筑日期',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '创建时间',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        align: 'center',
                        title: '汇总',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },

                ],
                [
                    {
                        field: 'totalCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'totalActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'totalRate',
                        align: 'center',
                        title: '合格率',
                    }
                ]
            ]
        };
        $.table.init(options);
    }

    /* 初始化 混凝土列表信息 */
    function queryConcreteList() {
        formatDate();

        var options = {
            id:"bootstrap-table",
            toolbar: "toolbar",
            uniqueId: "checkId",
            url: prefix + "/list",
            createUrl: prefix + "/add{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            pagination: true,
            modalName: "混凝土实测报表",
            columns: [
                [
                    {
                        checkbox: true,
                        rowspan: 2,
                        valign: "middle",
                        align: 'center'
                    },
                    {
                        field: 'checkId',
                        align: 'center',
                        title: '主键',
                        rowspan: 2,
                        valign: "middle",
                        visible: false
                    },
                    {
                        field: 'companyName',
                        align: 'center',
                        title: '工程公司',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'programName',
                        align: 'center',
                        title: '项目名称',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'buildingNumber',
                        align: 'center',
                        title: '工程部位',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'floorNumber',
                        align: 'center',
                        title: '结构部位',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'pouringTime',
                        align: 'center',
                        title: '浇筑日期',
                        sortable: true,
                        sortName:'pourTime',
                        rowspan: 2,
                        valign: "middle"
                    },

                    {
                        align: 'center',
                        title: '汇总',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },

                    {
                        align: 'center',
                        title: '垂直度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '平整度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '截面尺寸',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },

                    {
                        align: 'center',
                        title: '阴阳角',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '开间尺寸',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '顶板水平度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '楼板厚度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },


                    {
                        field: 'note',
                        align: 'center',
                        title: '备注',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'checkPerson',
                        align: 'center',
                        title: '录入人员',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'testPerson',
                        align: 'center',
                        title: '检测人员',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '创建时间',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        title: '操作',
                        align: 'center',
                        rowspan: 2,
                        valign: "middle",
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.checkId + '\',\'' + row.programName + '\',\'' + row.companyId + '\',\'' + row.programId + '\',)"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.checkId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            return actions.join('');
                        }
                    }
                ],
                [
                    {
                        field: 'totalCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'totalActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'totalRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'verticalityCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'verticalityActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'verticalityRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'planenessCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'planenessActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'planenessRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'sectionCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'sectionActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'sectionRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'angleCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'angleActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'angleRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'bayCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'bayActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'bayRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'roofCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'roofActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'roofRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'floorslabCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'floorslabActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'floorslabRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    }

                ]
            ]
        };
        $.table.init(options);
    }

    /* 初始化 砌体列表信息 */
    function queryBrickList() {
        formatDate();
        $('#add1').hide();
        var options = {
            id:"bootstrap-table1",
            toolbar: "toolbar1",

            uniqueId: "checkId",
            url: prefix + "/brickList",
            createUrl: prefix + "/add{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/removeBrick",
            exportUrl: prefix + "/exportBrick",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            pagination: true,
            modalName: "砌体实测报表",
            columns: [
                [
                    {
                        checkbox: true,
                        rowspan: 2,
                        valign: "middle",
                        align: 'center'
                    },
                    {
                        field: 'checkId',
                        align: 'center',
                        title: '主键',
                        rowspan: 2,
                        valign: "middle",
                        visible: false
                    },
                    {
                        field: 'companyName',
                        align: 'center',
                        title: '工程公司',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'programName',
                        align: 'center',
                        title: '项目名称',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'buildingNumber',
                        align: 'center',
                        title: '工程部位',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'floorNumber',
                        align: 'center',
                        title: '结构部位',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'pouringTime',
                        align: 'center',
                        title: '施工完成时间',
                        sortable: true,
                        sortName:'pourTime',
                        rowspan: 2,
                        valign: "middle"
                    },

                    {
                        align: 'center',
                        title: '汇总',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '垂直度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '平整度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '门窗洞口尺寸',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },

                    {
                        align: 'center',
                        title: '开间尺寸',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },

                    {
                        field: 'note',
                        align: 'center',
                        title: '备注',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'checkPerson',
                        align: 'center',
                        title: '录入人员',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'testPerson',
                        align: 'center',
                        title: '检测人员',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '创建时间',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        title: '操作',
                        align: 'center',
                        rowspan: 2,
                        valign: "middle",
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="editBrick(\'' + row.checkId + '\',\'' + row.programName + '\',\'' + row.companyId + '\',\'' + row.programId + '\',)"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.checkId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            return actions.join('');
                        }
                    }
                ],
                [

                    {
                        field: 'totalCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'totalActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'totalRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },
                    {
                        field: 'verticalityCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'verticalityActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'verticalityRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'planenessCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'planenessActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'planenessRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'doorCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'doorActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'doorRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },
                    {
                        field: 'bayCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'bayActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'bayRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    }
                ]
            ]
        };
        $.table.init(options);


    }

    /* 初始化 抹灰列表信息 */
    function queryPlasterList() {
        formatDate();
        $('#add2').hide();
        var options = {
            id:"bootstrap-table2",
            toolbar: "toolbar2",
            uniqueId: "checkId",
            url: prefix + "/plasterList",
            createUrl: prefix + "/add{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/removePlaster",
            exportUrl: prefix + "/exportPlaster",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            pagination: true,
            modalName: "抹灰实测报表",
            columns: [
                [
                    {
                        checkbox: true,
                        rowspan: 2,
                        valign: "middle",
                        align: 'center'
                    },
                    {
                        field: 'checkId',
                        align: 'center',
                        title: '主键',
                        rowspan: 2,
                        valign: "middle",
                        visible: false
                    },
                    {
                        field: 'companyName',
                        align: 'center',
                        title: '工程公司',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'programName',
                        align: 'center',
                        title: '项目名称',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'buildingNumber',
                        align: 'center',
                        title: '工程部位',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'floorNumber',
                        align: 'center',
                        title: '结构部位',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'pouringTime',
                        align: 'center',
                        title: '施工完成时间',
                        sortable: true,
                        sortName:'pourTime',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        align: 'center',
                        title: '汇总',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '垂直度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '平整度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '阴阳角',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },

                    {
                        align: 'center',
                        title: '开间尺寸',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },
                    {
                        align: 'center',
                        title: '地坪平整度',
                        rowspan: 1,
                        valign: "middle",
                        colspan: 3
                    },

                    {
                        field: 'note',
                        align: 'center',
                        title: '备注',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'checkPerson',
                        align: 'center',
                        title: '录入人员',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'testPerson',
                        align: 'center',
                        title: '检测人员',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '创建时间',
                        sortable: true,
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        title: '操作',
                        align: 'center',
                        rowspan: 2,
                        valign: "middle",
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="editPlaster(\'' + row.checkId + '\',\'' + row.programName + '\',\'' + row.companyId + '\',\'' + row.programId + '\',)"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.checkId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            return actions.join('');
                        }
                    }
                ],
                [
                    {
                        field: 'totalCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'totalActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'totalRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'verticalityCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'verticalityActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'verticalityRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'planenessCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'planenessActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'planenessRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'angleCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'angleActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'angleRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'bayCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'bayActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'bayRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    },

                    {
                        field: 'floorCheck',
                        align: 'center',
                        title: '检测点数'
                    },
                    {
                        field: 'floorActual',
                        align: 'center',
                        title: '合格点数'
                    },
                    {
                        field: 'floorRate',
                        align: 'center',
                        title: '合格率',
                        sortable: true,
                    }


                ]
            ]
        };
        $.table.init(options);


    }

    /* 初始化 树组件 */
    function queryProjectTree() {
        var url = prefix + "/treeData";
        var options = {
            url: url,
            expandLevel: 0,
            onClick: zOnClick
        };
        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            if (treeNode.grade == 1) {
                $("#companyId").val(treeNode.id);
                $("#proId").val("");

                $("#companyId0").val(treeNode.id);
                $("#proId0").val("");

                $("#companyId1").val(treeNode.id);
                $("#proId1").val("");

                $("#companyId2").val(treeNode.id);
                $("#proId2").val("");

                $("#companyId3").val(treeNode.id);
                $("#proId3").val("");

                $('#add').hide();
                $('#add1').hide();
                $('#add2').hide();
                $("#programId").val("");
                $("#programName").val("");

                // $("#companyId0").val("");
                // $("#proId0").val("");
                //
                // $("#companyId1").val("");
                // $("#proId1").val("");
                //
                // $("#companyId2").val("");
                // $("#proId2").val("");
                //
                // $("#companyId3").val("");
                // $("#proId3").val("");



                $.table.search("","bootstrap-table0","")
                $.table.search("","bootstrap-table","")
                $.table.search("","bootstrap-table1","")
                $.table.search("","bootstrap-table2","")

            } else if (treeNode.grade == 2) {
                debugger
                $("#companyId").val(treeNode.pId);
                $("#proId").val(treeNode.id);
                $("#programId").val(treeNode.id);
                $("#programName").val(treeNode.name);

                $("#companyId0").val(treeNode.pId);
                $("#proId0").val(treeNode.id);
                $("#programId0").val(treeNode.id);
                $("#programName0").val(treeNode.name);

                $("#companyId1").val(treeNode.pId);
                $("#proId1").val(treeNode.id);
                $("#programId1").val(treeNode.id);
                $("#programName1").val(treeNode.name);

                $("#companyId2").val(treeNode.pId);
                $("#proId2").val(treeNode.id);
                $("#programId2").val(treeNode.id);
                $("#programName2").val(treeNode.name);

                $("#companyId3").val(treeNode.pId);
                $("#proId3").val(treeNode.id);
                $("#programId3").val(treeNode.id);
                $("#programName3").val(treeNode.name);



                $('#add').show();
                $('#add1').show();
                $('#add2').show();

                $.table.search("","bootstrap-table0","")
                $.table.search("","bootstrap-table","")
                $.table.search("","bootstrap-table1","")
                $.table.search("","bootstrap-table2","")

                $("#companyId0").val("");
                $("#proId0").val("");
                $("#programId0").val("");
                $("#programName0").val("");

                $("#companyId1").val("");
                $("#proId1").val("");
                $("#programId1").val("");
                $("#programName1").val("");

                $("#companyId2").val("");
                $("#proId2").val("");
                $("#programId2").val("");
                $("#programName2").val("");

                $("#companyId3").val("");
                $("#proId3").val("");
                $("#programId3").val("");
                $("#programName3").val("");

            }
        }
    }

    /* 添加混凝土按钮 */
    function addConcreteView(companyId, proId, programName) {
        var url = "/concreteCheckManage/add?companyId=" + companyId + "&proId=" + proId + "&programName=" + programName;
        $.modal.openTab("添加混凝土实测报表", url);
    }

    /* 添加砌体按钮 */
    function addBrickView(companyId, proId, programName) {
        var url = "/concreteCheckManage/addBrickView?companyId=" + companyId + "&proId=" + proId + "&programName=" + programName;
        $.modal.openTab("添加砌体实测报表", url);
    }

    /* 添加抹灰按钮 */
    function addPlasterView(companyId, proId, programName) {
        var url = "/concreteCheckManage/addPlasterView?companyId=" + companyId + "&proId=" + proId + "&programName=" + programName;
        $.modal.openTab("添加抹灰实测报表", url);
    }

    /* 混凝土-编辑按钮 */
    function edit(checkId,programName,companyId,programId) {
        var url = prefix + '/editListView?checkId=' + checkId+'&programName='+programName+'&companyId='+companyId+'&programId'+programId;
        $.modal.openTab("报表编辑", url);
    }

    /* 砌体-编辑按钮 */
    function editBrick(checkId,programName,companyId,programId) {
        var url = prefix + '/editBrickView?checkId=' + checkId+'&programName='+programName+'&companyId='+companyId+'&programId'+programId;
        $.modal.openTab("报表编辑", url);
    }

    /* 抹灰-编辑按钮 */
    function editPlaster(checkId,programName,companyId,programId) {
        var url = prefix + '/editPlasterView?checkId=' + checkId+'&programName='+programName+'&companyId='+companyId+'&programId'+programId;
        $.modal.openTab("报表编辑", url);
    }

    /* 混凝土-导出按钮 */
    function exportExcel(fileName) {
        var data = {
            companyId: $("#companyId").val(),
            programId: $("#programId").val(),
            programName: $("#progName").val(),
            buildingNumber: $("#buildingNumber").val(),
            floorNumber: $("#floorNumber").val(),
        }

        $.modal.confirm("确定导出所有混凝土吗？", function () {
            $.modal.loading("正在导出数据，请稍后...");
            $.post("/concreteCheckManage/export", data, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + fileName + ".xls&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }

    /* 砌体-导出按钮 */
    function exportBrickExcel(fileName) {
        var data = {
            companyId: $("#companyId").val(),
            programId: $("#programId").val(),
            programName: $("#progName").val(),
            buildingNumber: $("#buildingNumber").val(),
            floorNumber: $("#floorNumber").val(),
        }

        $.modal.confirm("确定导出所有砌体吗？", function () {
            $.modal.loading("正在导出数据，请稍后...");
            $.post("/concreteCheckManage/exportBrick", data, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + fileName + ".xls&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }

    /* 抹灰-导出按钮 */
    function exportPlasterExcel(fileName) {
        var data = {
            companyId: $("#companyId").val(),
            programId: $("#programId").val(),
            programName: $("#progName").val(),
            buildingNumber: $("#buildingNumber").val(),
            floorNumber: $("#floorNumber").val(),
        }

        $.modal.confirm("确定导出所有抹灰吗？", function () {
            $.modal.loading("正在导出数据，请稍后...");
            $.post("/concreteCheckManage/exportPlaster", data, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + fileName + ".xls&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }

    /* 汇总-导出按钮 */
    function exportOutlineExcel(fileName) {
        var data = {
            companyId: $("#companyId").val(),
            programId: $("#programId").val(),
            programName: $("#progName").val(),
            buildingNumber: $("#buildingNumber").val(),
            floorNumber: $("#floorNumber").val(),
        }

        $.modal.confirm("确定导出所有工艺汇总吗？", function () {
            $.modal.loading("正在导出数据，请稍后...");
            $.post("/concreteCheckManage/exportOutline", data, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + fileName + ".xls&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }

    /* 导出所有-导出按钮 */
    function exportExcelAll(fileName) {
        var data = {
            companyId: $("#companyId").val(),
            programId: $("#programId").val(),
            programName: $("#progName").val(),
            buildingNumber: $("#buildingNumber").val(),
            floorNumber: $("#floorNumber").val(),
        }

        $.modal.confirm("确定导出所有工艺报表吗？", function () {
            $.modal.loading("正在导出数据，请稍后...");
            var url = prefix + "/exportAll";
            $.post(url, data, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + fileName + ".xls&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }

    /* 初始化树组件 > 展开 */
    $('#btnExpand').click(function () {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    /* 初始化树组件 > 折叠 */
    $('#btnCollapse').click(function () {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    /* 初始化树组件 > 刷新 */
    $('#btnRefresh').click(function () {
        queryProjectTree();
    });

    function formatDate() {
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            laydate.render({
                elem: '#pouringTime0'
            });

            laydate.render({
                elem: '#pouringTime'
            });

            laydate.render({
                elem: '#pouringTime1'
            });

            laydate.render({
                elem: '#pouringTime2'
            });

        });
    }

</script>
</body>
</html>